﻿using FS.Common.DotNetBean;
using FS.Common.DotNetCode;
using FS.Common.DotNetUI;
using FS.Business;
using System;
using System.Collections;
using System.Data;
using System.Text;
using System.Collections.Generic;

namespace FS.Web.BLL.Visa_info
{
    public partial class Visa_InfoAuditBatchForm : PageBase
    {
        private string _key;
        private visa_dao _visa = new visa_dao();
        protected void Page_Load(object sender, EventArgs e)
        {
            this._key = base.Request["key"];
            if (!base.IsPostBack)
            {
                GetSelect_City();
                GetSelect_Operation();
                GetSelect_moneytype();
                GetSelect_moneyflag();
                GetSelect_CertType();
                GetSelect_Supply();
                if (!string.IsNullOrEmpty(this._key))
                {
                    //this.InitData();
                }

                #region 权限控制
                string ls_viewSupply = RequestSession.GetSessionUser().isViewSupply;
                string ls_viewPrice = RequestSession.GetSessionUser().isViewPrice;
                string ls_viewCost = RequestSession.GetSessionUser().isViewCost;
                if (ls_viewSupply == "0")
                {
                    this.div_supply.Visible = false;
                }
                if (ls_viewPrice == "0")
                {
                    this.div_price.Visible = false;
                }
                if (ls_viewCost == "0")
                {
                    this.div_cost.Visible = false;
                }
                #endregion
            }
        }

        #region 下拉数据
        //所属国家
        private void GetSelect_City()
        {
            DataTable dt = _visa.GetSelect_CityInfo();
            ControlBindHelper.BindHtmlSelect(dt, this.City_id, "city_name", "city_id", "请选择");
        }

        //签证类型
        private void GetSelect_CertType()
        {
            DataTable dt = _visa.GetSelect_CertType();
            ControlBindHelper.BindHtmlSelect(dt, this.Ref_CertType, "property_value", "property_key", "请选择");
        }

        //供应商
        private void GetSelect_Supply()
        {

            DataTable dt = _visa.GetSelect_SupplyInfoSimple();
            ControlBindHelper.BindHtmlSelect(dt, this.Supply_id, "supply_name", "supply_id", "请选择");
        }

        //经办人
        private void GetSelect_Operation()
        {
            DataTable dt = this._sys_idao.GetSelect_CurrentUserList();
            ControlBindHelper.BindHtmlSelect(dt, this.InfoDetail_operationid, "user_name", "user_id", "请选择");
        }
        //收款方式
        private void GetSelect_moneytype()
        {
            DataTable dt = _visa.GetSelect_moneytype();
            ControlBindHelper.BindHtmlSelect(dt, this.Ref_moneytype, "property_value", "property_key", "请选择");
        }

        //收款情况
        private void GetSelect_moneyflag()
        {
            DataTable dt = _visa.GetSelect_moneyflag();
            ControlBindHelper.BindHtmlSelect(dt, this.Ref_moneyflag, "property_value", "property_key", "请选择");
        }
        #endregion

        private void InitData()
        {
            
        }

        protected void Save_Click(object sender, EventArgs e)
        {
            string ls_city = this.City_id.Items[this.City_id.SelectedIndex].Value;
            string ls_certtype = this.Ref_CertType.Items[this.Ref_CertType.SelectedIndex].Value;
            string ls_supplyid = this.Supply_id.Items[this.Supply_id.SelectedIndex].Value;
            string ls_operationid = this.InfoDetail_operationid.Items[this.InfoDetail_operationid.SelectedIndex].Value;
            string ls_operationname = this.InfoDetail_operationid.Items[this.InfoDetail_operationid.SelectedIndex].Text;
            string ls_moneytype = this.Ref_moneytype.Items[this.Ref_moneytype.SelectedIndex].Value;
            string ls_moneyflag = this.Ref_moneyflag.Items[this.Ref_moneyflag.SelectedIndex].Value;
            string ls_infoflag = this.ref_infoflag.Items[this.ref_infoflag.SelectedIndex].Value;
            string ls_price = this.InfoDetai_BegPrice.Value;
            string ls_cost = this.InfoDetai_EndPrice.Value;
            string ls_fulldata = this.Data_integrity.Items[this.Data_integrity.SelectedIndex].Value;
            string ls_rmk = this.InfoDetail_remark.Value.Trim();
            string ls_Financel_remark = this.Financel_remark.Value.Trim();
            string[] pkid=this._key.Split(',');

            bool IsOk = _visa.InfoAudit_BatchUpdate(pkid, ls_city, ls_certtype, ls_supplyid, ls_operationid, ls_operationname,
                ls_moneytype,ls_moneyflag,ls_infoflag,ls_price,ls_cost,ls_fulldata,ls_rmk,ls_Financel_remark,_userid,_username);
            if (IsOk)
            {
                ShowMsgHelper.AlertMsg("操作成功！");
            }
            else
            {
                ShowMsgHelper.Alert_Error("操作失败！");
            }            
            
        }
    }
}